/**
 * 函数节流
 * @param  {Function} func [原函数]
 * @param  {Number}   wait [间隔时间]
 * @param  {Blooean}  immediate [是否立即执行]
 * @return {Function}   [节流函数]
 */
 const throttle = (func,wait,immediate = true) => {
	 let lastTime = 0
	 return function (...args){
		 const nowTime = + new Date()
		 if(immediate){
				immediate = false
				lastTime = nowTime
				func.apply(this,args)
		 }else{
			 if(nowTime - lastTime >= wait){
				 lastTime = nowTime
				 func.apply(this,args)
			 }
		 }
	 }
 }
 
 export default throttle